import User from "@/interfaces/User";
import { getQuery } from "@/lib/client"
import viewer from "@/queries/viewer.gql"
import { redirect } from "next/navigation";
export const authQuery = async (back = "/home") => {
    const { data, error } = await getQuery<User>(viewer);
    if (!!error || !data) return redirect(`auth?back=${encodeURI(back)}`)
    return data
}